package nccloud.web.ic.inbound.generalin.action;

import nc.itf.ic.ic_gapply.gapplyheadvo.IGapplyHeadVOService;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.ic.icgapply.GapplyVO;
import nccloud.dto.scmpub.page.entity.SCMQueryTreeFormatVO;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory;
import nccloud.framework.web.ui.pattern.billgrid.BillGrid;
import nccloud.framework.web.ui.pattern.billgrid.BillGridOperator;
import nccloud.pubitf.platform.query.INCCloudQueryService;

public class QueryRef488SAction implements ICommonAction {
	public Object doAction(IRequest request) {
		String read = request.read();
		IJson json = JsonFactory.create();
		SCMQueryTreeFormatVO info = (SCMQueryTreeFormatVO) json.fromJson(read, SCMQueryTreeFormatVO.class);
		INCCloudQueryService queryutil = (INCCloudQueryService) ServiceLocator.find(INCCloudQueryService.class);
		IQueryScheme scheme = queryutil.convertCondition(info.getQueryInfo());
		String searchSql = "";
		if(scheme != null && scheme.getWhereSQLOnly() != null) {
			searchSql = scheme.getWhereSQLOnly();
		}
		
		try {			
			IGapplyHeadVOService service = ServiceLocator.find(IGapplyHeadVOService.class);
			GapplyVO[] vos = service.listGapplyVOByCondition(searchSql);
			
			if (vos != null) {
				BillGridOperator operator = new BillGridOperator(info.getTempletid(), info.getPageCode());
				BillGrid[] grids = operator.toBillGrids(vos);
//				BillGrid[] var13 = grids;
//				int var14 = grids.length;

//				for (int var15 = 0; var15 < var14; ++var15) {
//					BillGrid grid = var13[var15];
//					(new AssignSetScaleField()).setFieldsScale(grid);
//				}

				return grids;
			}
		} catch (Exception var17) {
			ExceptionUtils.wrapException(var17);
		}

		return null;
	}
}